﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LabyCLI.Commands
{
    class cmd_type
    {
        Terminal frm = frmMain.Instance;

        public void Main(List<string> args)
        {
            foreach (string arg in args)
            {
                if (File.Exists(arg))
                {
                    string[] lines = File.ReadAllLines(arg);

                    Terminal.WriteLine(Environment.NewLine + "Content of: " + arg);

                    StringBuilder sb = new StringBuilder();

                    foreach (string line in lines)
                    {
                        sb.AppendLine(line);
                    }

                    sb.AppendLine(string.Empty);

                    string output = sb.ToString();

                    Terminal.Write(output);
                }
                else
                {
                    Terminal.WriteLine("Invaild file: " + arg + Environment.NewLine, Properties.Settings.Default.Terminal_ErrorForeColor);
                }
            }
        }

        public void Main()
        {
            Terminal.WriteLine("Invaild amount of arguments." + Environment.NewLine, Properties.Settings.Default.Terminal_ErrorForeColor);
        }
    }
}
